/**
 * @description  : 第三方人员预览签名
 * @descriptionDetail : 第三方人员预览签名
 * @copyright    : 浙江烟草
 * @author       : lcm
 * @create       : 2022-12-05 16:22:02
 */
<template>
  <view class="page">
    <view v-if="isExpired" class="content u-page pdf-container">
      <web-view :src="pdfSrc" style="bottom: 44px !important;"></web-view>
    </view>
    <view v-if="isExpired" class="sign-btn">
      <u-button type="primary" @tap="onSign">
        签名
      </u-button>
    </view>
  </view>
</template>
<script>
import { PATHROOT, } from '@/common/path.config.js';
export default {
  onLoad() {
    let param = this.options;
    this.fileId = param.fileId;  // 文件id
    this.fileName = param.fileName; // 文件名 可不传
    this.isExpired = !param.et || param.et * 1 > new Date().getTime();   // 过期时间
    if (!this.isExpired) {
      this.$modal.alert("签名已失效，如需重新签名，请联系业务人员！");
    }
  },
  data() {
    return {
      fileUrl: PATHROOT.BASE + "/commonfile/filestore/downloadFilePdf.do",
      userInfo: this.$storage.get(this.$rp.common.USER),
      fileId: "",
      fileName: "",
      pdfSrc:"",
      isIos:false,
      isExpired: false,   // 是否过期
    };
  },
  mounted() {
    if (this.fileName) {
      this.navTitle = this.fileName;
    }
    this.fileUrl = PATHROOT.BASE + "/commonfile/filestore/downloadFile.do";
    this.init();
  },
  methods: {
    init() {
      this.pdfSrc = location.origin + location.pathname + "/pdf/web/view.html?file=" + encodeURIComponent(this.genericPath());
    },
    /**
	 * 生成预览路径
	 * @returns {string}
	 */
    genericPath() {
      return this.fileUrl + "?tk=" + this.userInfo.tk + "&fileId=" + this.fileId;
    },
    // TODO 对接签章中心进行签名
    onSign() {
      
    },
  },
};
</script>
<style lang="scss" scoped>
	@import "@/style/common/rightMenu.scss";
	.pdf-container {
		height: calc(100% - 44px);
		width: 100%;
	}

	iframe {
		height: 100%;
		min-height: 480px;
		width: 100%;
    margin-bottom: 44px;
	}
  .sign-btn {
    position: fixed;
    height: 44px;
    width: 100%;
    bottom: 0px;
    left: 0px;
    z-index: 99;
  }
</style>
